<extend name="Public/base"/>

<block name="style">
	<link rel="stylesheet" href="__STATIC__/plugins/data-tables/DT_bootstrap.css" />
</block>

<!-- 子导航 -->
<block name="sidebar">
    <include file="sidemenu" />
</block>


<block name="body">

	<!-- 数据表格 -->
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN EXAMPLE TABLE PORTLET-->
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="fa fa-globe"></i>我的文档({$_total})</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                        <a href="#portlet-config" data-toggle="modal" class="config"></a>
                        <a href="javascript:;" class="reload"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="table-toolbar">
                        <div class="btn-group">
                            <button class="btn green ajax-post" target-form="ids" url="{:U("Article/setStatus",array("status"=>1))}">启 用</button>
                            <button class="btn green ajax-post" target-form="ids" url="{:U("Article/setStatus",array("status"=>0))}">禁 用</button>
                            <button class="btn green ajax-post confirm" target-form="ids" url="{:U("Article/setStatus",array("status"=>-1))}">删 除</button>
                        </div>
                        <div class="btn-group pull-right">
                        	
                            <div class="input-group input-medium">
                                <input type="text" class="form-control search-input" name="title" placeholder="名称、CAS号">
                                <span class="input-group-btn">
                                <button class="btn green" type="button"  id="search" url="{:U('Article/mydocument')}">搜索</button>
                                </span>
                            </div>

                        </div>
                    </div>
                    <table class="table table-striped table-bordered table-hover" id="sample">
                        <thead>
                            <tr>
                                <th class="table-checkbox"><input type="checkbox" class="group-checkable" data-set="#sample .checkboxes" /></th>
                                <th class="">编号</th>
                                <th class="">标题</th>
                                <th class="">分类</th>
                                <th class="">最后更新</th>
                                <th class="">状态</th>
                                <th class="">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        	<volist name="list" id="vo">
                            <tr class="odd gradeX">
                                
                                <td><input class="checkboxes ids" type="checkbox" name="ids[]" value="{$vo.id}" /></td>
                                <td>{$vo.id} </td>
                                <td><a href="{:U('Article/edit?cate_id='.$vo['category_id'].'&id='.$vo['id'])}">{$vo.title}</a></td>
                                <td><span>{:get_cate($vo['category_id'])}</span></td>
                                <td><span>{$vo.update_time|time_format}</span></td>
                                <td>{$vo.status_text}</td>
                                <td><a href="{:U('Article/edit?cate_id='.$vo['category_id'].'&id='.$vo['id'])}">编辑</a>
                                    <a href="{:U('Article/setStatus?ids='.$vo['id'].'&status='.abs(1-$vo['status']))}" class="ajax-get">{$vo.status|show_status_op}</a>
                                    <a href="{:U('Article/setStatus?status=-1&ids='.$vo['id'])}" class="confirm ajax-get">删除</a>
                                    </td>
                            </tr>
                            </volist>
                        </tbody>
                    </table>
    
                    <!-- 分页 -->
                    <div class="page">
                        {$_page}
                    </div>
                </div>
            </div>
            <!-- END EXAMPLE TABLE PORTLET-->
        </div>
    </div>
</div>

</block>

<block name="script">
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script type="text/javascript" src="__STATIC__/plugins/data-tables/jquery.dataTables.js"></script>
	<script type="text/javascript" src="__STATIC__/plugins/data-tables/DT_bootstrap.js"></script>
	<!-- END PAGE LEVEL PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="__STATIC__/scripts/app.js"></script>
	<script src="__STATIC__/scripts/table-managed.js"></script>     
	<script>
		jQuery(document).ready(function() {       
		   App.init();
		   TableManaged.init();
			//搜索功能
			$("#search").click(function(){
				var url = $(this).attr('url');
				var query = $(".search-input").serialize();
				query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
				query = query.replace(/^&/g,'');

				if( url.indexOf('?')>0 ){
					url += '&' + query;
				}else{
					url += '?' + query;
				}
				window.location.href = url;
			});
		});
	</script>
</block>
